#include <stdio.h>
#include <string.h>

int year(int y)
{
	if ((y%400==0) || ((y%4==0) && (y%100!=0))) {
		return 1;
	} else {
		return 0;
	}
}

int month(int y, int m)
{
	if (m == 2 && year(y)) {
		return 29;
	} else {
		int marray[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
		return marray[m-1];
	}
}

int main(int argc, char *argv[])
{
	char s[16], buf[5];
	scanf("%s", s);

	int y, m, d;
	strncpy(buf, s, 4);
	buf[4] = '\0';
	y = atoi(buf);

	if (s[6] == '-') {
		strncpy(buf, &s[5], 1);
		buf[1] = '\0';
		m = atoi(buf);
		if (s[8] == '\0') {
			strncpy(buf, &s[7], 1);
			buf[1] = '\0';
			d = atoi(buf);
		} else {
			strncpy(buf, &s[7], 2);
			buf[2] = '\0';
			d = atoi(buf);
		}
	} else {
		strncpy(buf, &s[5], 2);
		buf[2] = '\0';
		m = atoi(buf);
		if (s[9] == '\0') {
			strncpy(buf, &s[8], 1);
			buf[1] = '\0';
			d = atoi(buf);
		} else {
			strncpy(buf, &s[8], 2);
			buf[2] = '\0';
			d = atoi(buf);
		}

	}

	int sum = 0, i;
	for (i = 1; i < m; i++) {
		sum += month(y, i);
	}
	sum += d;

	printf("%d\n", sum);

	return 0;
}
